package com.weimob.mcloud.wechatwork.customer.export;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.weimob.mcloud.wechatwork.customer.export.sentinel.SentinelCommonBlockHandler;
import com.weimob.mcloud.wechatwork.customer.facade.impl.customer.CustomerLoseFacade;
import com.weimob.mcloud.wechatwork.customer.service.user.base.BaseRequest;
import com.weimob.mcloud.wechatwork.customer.service.user.module.bo.customer.CustomerLoseLogBO;
import com.weimob.mcloud.wechatwork.customer.service.user.module.bo.customer.CustomerPageResponse;
import com.weimob.mcloud.wechatwork.customer.service.user.module.bo.customer.EmployDeleteCustomerAlarmBO;
import com.weimob.mcloud.wechatwork.customer.service.user.module.dto.customer.CustomerLoseLogQueryDTO;
import com.weimob.mcloud.wechatwork.customer.service.user.module.dto.customer.EmployDeleteCustomerAlarmDTO;
import com.weimob.mcloud.wechatwork.customer.service.user.module.dto.customer.openapi.CustomerLoseApi;
import com.weimob.mcloud.wechatwork.customer.service.user.service.CustomerLoseExport;
import com.weimob.mcloud.wechatwork.customer.service.user.utils.SoaResponseUtil;
import com.weimob.soa.common.response.SoaResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class CustomerLoseExportImpl implements CustomerLoseExport {

    @Autowired
    private CustomerLoseFacade customerLoseFacade;


    @Override
    public SoaResponse<CustomerPageResponse<CustomerLoseLogBO>, ?> queryCustomerDeleteEmployList(CustomerLoseLogQueryDTO customerLoseLogQueryDTO) {
        return SoaResponseUtil.ok(customerLoseFacade.query(customerLoseLogQueryDTO));

    }
    @Override
    public SoaResponse<Boolean, ?> customerDeleteEmployListExport(CustomerLoseLogQueryDTO customerLoseLogQueryDTO) {
        return SoaResponseUtil.ok(customerLoseFacade.customerDeleteEmployListExport(customerLoseLogQueryDTO));
    }

    @Override
    public SoaResponse<Boolean, ?> employDeleteCustomerAlarm(EmployDeleteCustomerAlarmDTO employDeleteCustomerAlarmDTO) {
        return SoaResponseUtil.ok(customerLoseFacade.employDeleteCustomerAlarm(employDeleteCustomerAlarmDTO));
    }

    @Override
    public SoaResponse<EmployDeleteCustomerAlarmBO, ?> getAlarmDetail(BaseRequest request) {
        return SoaResponseUtil.ok(customerLoseFacade.getAlarmDetail(request));
    }

    @Override
    public SoaResponse<CustomerPageResponse<CustomerLoseLogBO>, ?> customerLoseExportInfo(CustomerLoseLogQueryDTO customerLoseLogQueryDTO) {
        return SoaResponseUtil.ok(customerLoseFacade.customerLoseExportInfo(customerLoseLogQueryDTO));
    }

    @Override
    @SentinelResource(value = "queryLoseList", blockHandlerClass = SentinelCommonBlockHandler.class, blockHandler = "queryLoseListBlockHandler")
    public SoaResponse<CustomerPageResponse<CustomerLoseLogBO>, ?> queryLoseList(CustomerLoseApi api) {
        //入参转换
        CustomerLoseLogQueryDTO customerLoseLogQueryDTO = new CustomerLoseLogQueryDTO();
        BeanUtils.copyProperties(api, customerLoseLogQueryDTO);
        customerLoseLogQueryDTO.setBasicInfo(api.convertToBasicInfo());
        return SoaResponseUtil.ok(customerLoseFacade.query(customerLoseLogQueryDTO));

    }

}
